package spring.service;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import spring.event.RegisterEvent;

/**
 * @author huu
 * @create 2025-08-25-14:54
 */
@Component
public class giftService {

    @Async
    @EventListener
    public void onRegister(RegisterEvent event) throws InterruptedException {
        System.out.println("开始处理用户注册事件: " + event.getUser() + "，线程: " + Thread.currentThread().getName());
        Thread.sleep(5000); // 模拟耗时操作
        System.out.println("gift For" + event.getUser());
    }

}
